package com.dotstone.chipism.activity;


import com.dotstone.chipism.R;
import com.dotstone.chipism.util.SPUtils;
import com.dotstone.chipism.view.StatusBarUtils;
import android.content.Context;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class AboutUsActivity extends BaseActivity {
	private LinearLayout mBackL;
	private TextView mTitleT;
	private TextView mVersionT;
	private TextView mVersionT1;
	private TextView tv_statusBar_mian;
	@Override
	public void widgetClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.back_layout:
			finish();
			break;
		case R.id.version_tv1:
			//点击进行升级
			break;
		default:
			break;
		}
	}

	@Override
	public void initParms(Bundle parms) {
		// TODO Auto-generated method stub

	}

	@Override
	public View bindView() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int bindLayout() {
		// TODO Auto-generated method stub
		return R.layout.activity_about;
	}

	@Override
	public void initView(View view) {
		// TODO Auto-generated method stub
		mBackL = $(R.id.back_layout);
		tv_statusBar_mian = $(R.id.tv_statusBar_mian);
		mTitleT = $(R.id.title_tv);
		mTitleT.setVisibility(View.VISIBLE);
		mTitleT.setText("关于我们");
		mVersionT = $(R.id.version_tv);
		mVersionT1 = $(R.id.version_tv1);
		boolVersion();
		mBackL.setOnClickListener(this);
		mVersionT1.setOnClickListener(this);
		initVersion();
	}

	private void initVersion() {
		// TODO Auto-generated method stub
		String pkName = this.getPackageName();
		try {
			String versionName = this.getPackageManager().getPackageInfo(
						pkName, 0).versionName;
			mVersionT.setText("当前版本："+versionName);
			String versionName1 = (String) SPUtils.get(getApplicationContext(), "newversion", "");
			mVersionT1.setText(versionName1);
		} catch (NameNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	@Override
	public void setListener() {
		// TODO Auto-generated method stub

	}

	@Override
	public void doBusiness(Context mContext) {
		// TODO Auto-generated method stub

	}
	
	public void boolVersion() {
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {

			Window window = getWindow();
			window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
					WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
			// 透明导航栏
			// getWindow().addFlags(
			// WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
			// 改变titlebar的高度
			int statusbarHeight = StatusBarUtils.getHeight(this);
			RelativeLayout.LayoutParams layoutParams1 = (RelativeLayout.LayoutParams) tv_statusBar_mian
					.getLayoutParams();
			layoutParams1.height = statusbarHeight;
			tv_statusBar_mian.setLayoutParams(layoutParams1);
			tv_statusBar_mian.setVisibility(View.VISIBLE);

		} else {
			tv_statusBar_mian.setVisibility(View.GONE);
		}
	}

}
